package logic

import (
	"context"
	"errors"
	"srv/models"

	"srv/house"
	"srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type HousePersonListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHousePersonListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HousePersonListLogic {
	return &HousePersonListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *HousePersonListLogic) HousePersonList(in *house.HousePersonListRequest) (*house.HousePersonListResponse, error) {
	// todo: add your logic here and delete this line
	var newUser models.User
	err := newUser.FirstUser(int(in.UserId))
	if err != nil {
		logx.Error("用户未登录")
		return nil, errors.New("用户未登录")
	}
	var newHouse models.House
	houses := newHouse.PersonListHouse(int(in.UserId))
	return &house.HousePersonListResponse{
		List: houses,
	}, nil
}
